package byggeTegning.husGeometri;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;

import javax.media.j3d.Group;
import javax.vecmath.Color3f;

import byggeTegning.geometry.Point3D;


// ***************************************************************************
// *** CLASS: SalTakSki
// ***************************************************************************
public class SalTakSki extends BjelkeLag
{
  SalTakEndeBord vannBord;
  SalTakEndeBord toppSki;
  SalTakEndeBord bunnSki;
  double takskiHoyde=0.45;//35; //17;
  double takskiUtspring=0.50;//0.60; // Utspring
  double takskiSkjevhet=0.30; // Skias skjevhet i front
    
  public SalTakSki
  (String ident,Point3D p0,double tanTakvinkel,double width,double height,double depth,boolean west)
  { super(ident,p0,width,height,depth);
    // VannBord
    { double vannBordHoyde=0.025; // 2.5 cm
      double vannBordUtspring=takskiUtspring+takskiSkjevhet+0.12;
      double vannBordSkjevhet=0.03;//0.075;
//      Point3D pVannBord=p0.addY(takskiHoyde).addZ(depth/2-0.05);
      Point3D pVannBord=p0.addY(takskiHoyde).addX(width/2-0.05);
      this.vannBord=
        new SalTakEndeBord(ident,pVannBord,tanTakvinkel,0.10,height,depth,
              vannBordHoyde,vannBordUtspring,vannBordSkjevhet);
    }          
    // ToppSki
    { double toppSkiHoyde=0.30; // 30 cm
      double toppSkiUtspring=takskiUtspring+takskiSkjevhet/3;
      double toppSkiSkjevhet=takskiSkjevhet;
//      Point3D pToppSki=p0.addY(0.15).addZ((north)?-depth:+depth);
      Point3D pToppSki=p0.addY(0.15).addX((west)?-width:+width);
      this.toppSki=
        new SalTakEndeBord(ident,pToppSki,tanTakvinkel,width,height,depth,
              toppSkiHoyde,toppSkiUtspring,toppSkiSkjevhet);
    }          
    // BunnSki
    { double bunnSkiHoyde=0.30; // 30 cm
      double bunnSkiUtspring=takskiUtspring-takskiSkjevhet/4;
      double bunnSkiSkjevhet=takskiSkjevhet;
      this.bunnSki=
        new SalTakEndeBord(ident,p0,tanTakvinkel,width,height,depth,
              bunnSkiHoyde,bunnSkiUtspring,bunnSkiSkjevhet);
    }          
  }
  
  // ***************************************************************************
  // *** METHOD: getModel3D
  // ***************************************************************************
  public /*abstract*/ Group getModel3D(Color3f c)
  {
//    TransformedGroup3D tg=new TransformedGroup3D();
    Group tg=new Group();
    tg.addChild(vannBord.getModel3D(c));
    tg.addChild(toppSki.getModel3D(c));
    tg.addChild(bunnSki.getModel3D(new Color3f(uthusFarge)));
    return(tg);
  }  

  public void drawProjection(int direction,Graphics2D g,Point2D.Double origo2D,double scale,Color c)
  { bunnSki.drawProjection(direction,g,origo2D,scale,uthusFarge);
    toppSki.drawProjection(direction,g,origo2D,scale,c);
    vannBord.drawProjection(direction,g,origo2D,scale,c);
  }  

}  
